<template>
  <div class="mainContainer">
    <div class="left">
      <el-input
        placeholder="输入关键字进行过滤"
        v-model="filterText"
        style="margin-bottom: 10px"
      >
      </el-input>
      <el-tree
        class="filter-tree"
        :data="data"
        :props="defaultProps"
        accordion
        :filter-node-method="filterNode"
        @node-click="turn"
        ref="tree"
      >
      </el-tree>
    </div>
    <div class="right">
      <div class="bottom">
        <el-button type="primary">选择文件上传</el-button>
      </div>
      <div class="top">
        <el-table :data="fileData" style="width: 100%">

          <el-table-column label="上传日期" width="250">
            <template slot-scope="scope">
              <i class="el-icon-time"></i>
              <span style="margin-left: 10px">{{ scope.row.date }}</span>
            </template>
          </el-table-column>

          <el-table-column label="文件名称" width="380">
            <template slot-scope="scope">
              <span style="margin-left: 10px">{{ scope.row.filename }}</span>
            </template>
          </el-table-column>

          <el-table-column label="操作">
            <template slot-scope="scope">
              <el-button
                size="mini"
                @click="handleEdit(scope.$index, scope.row)"
                >下载</el-button
              >
              <el-button
                size="mini"
                type="danger"
                @click="handleDelete(scope.$index, scope.row)"
                >删除</el-button
              >
            </template>
          </el-table-column>
          
        </el-table>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      search: "",
      fileData: [
        {
          date: "2016-05-02",
          filename: "物理第一章习题",
        },
        {
          date: "2016-05-04",
          filename: "英语复习",
        },
        {
          date: "2016-05-01",
          filename: "物理第二章复习",
        },

      ],
      tableData: null,
      filterText: "",
      data: [
        {
          id: 1,
          label: "2021年下学期",
          children: [
            {
              id: 9,
              label: "机械一班",
            },
            {
              id: 10,
              label: "机械三班",
            },
          ],
        },
        {
          id: 1,
          label: "2021年上学期",
          children: [
            {
              id: 9,
              label: "计算机一班",
            },
            {
              id: 10,
              label: "计算机三班",
            },
          ],
        },
        {
          id: 1,
          label: "2020年上学期",
          children: [
            {
              id: 9,
              label: "电气一班",
            },
            {
              id: 10,
              label: "电气三班",
            },
          ],
        },
      ],
      defaultProps: {
        children: "children",
        label: "label",
      },
    };
  },
  mounted() {},
  methods: {
    filterNode(value, data) {
      if (!value) return true;
      return data.label.indexOf(value) !== -1;
    },
    turn(data) {
      this.$message("成功转到" + data.label + "该结点");
    },
  },
};
</script>

<style lang="less" scoped>
.mainContainer {
  height: 100%;
  width: 100%;
  display: flex;
}
.left {
  height: 100%;
  width: 20%;
  display: block;
  padding: 10px;
}
.right {
  height: 100%;
  width: 80%;
  display: flex;
  padding: 10px;
  flex-wrap: wrap;
}
.top {
  height: 90%;
  width: 100%;
}
.bottom {
  height: 10%;
  width: 100%;
  display: flex;
  justify-content: right;
  align-items: center;
}
</style>>